﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
using System.Resources;
using System.Globalization;

namespace QLCHQA
{
    public partial class Lua_chon : Form
    {
         DataTable dt;
        SqlDataAdapter da;
        DataSet ds;
        string id;
        public Lua_chon()
        {
            InitializeComponent();
        }

        public void chuyendl(string id)
        {
            this.id = id;
        }

        private void Lua_chon_Load(object sender, EventArgs e)
        {

            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = ConfigurationManager.AppSettings["conStr"];
            dt = new DataTable();
            ds = new DataSet();
            String sql = "select * from nhanvien where id = '" + id + "'";
            da = new SqlDataAdapter(sql, conn);
            da.Fill(ds, "acc");
            dt = ds.Tables["acc"];
            if (dt.Rows.Count != 0)
            {
                DataRow dr = dt.Rows[0];
                string ten = dr[3] + "";
                string cv = dr[5] + "";
                txtTen.Text = ten;
                ql_lc.Enabled = false;
                this.nvkho_lc.Enabled = false;
                this.nvbh_lc.Enabled = false;
                if (cv == "Nhân viên bán hàng")
                {
                    this.nvbh_lc.Enabled = true;
                }
                else
                    if (cv == "Nhân viên kho")
                    {
                        this.nvkho_lc.Enabled = true;
                    }
                    else
                    {
                        this.ql_lc.Enabled = true;
                    }
            }
        }


        private void bánHàngToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Ban_hang fr = new Ban_hang();
            fr.Show();
            this.Hide();
            fr.chuyendl(id);
        }

        private void kiểmTraHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Search s = new Search();
            s.chuyendl(id);
            s.Show();
            this.Close();
        }

        private void nhậpHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Nhap nhap = new Nhap();
            nhap.chuyendl(id);
            nhap.Show();
            this.Close();
        }

        private void thayĐổiMậtKhẩuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Thay_Doi_MK f = new Thay_Doi_MK();
      
            f.chuyendl(id);
            f.Show();
        }

        private void thoátChươngTrìnhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void đăngKíKHTTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DangkiKH dk = new DangkiKH();
            dk.chuyendl(id);
            dk.Show();
            this.Close();
        }

        private void thêmHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddSP ad = new AddSP();
            ad.chuyendl(id,"");
            ad.Show();
            this.Close();
        }

        private void thốngKêNgàyToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            TKBan nhap = new TKBan();
            nhap.chuyendl(id);
            nhap.Show();
            this.Close();
        }

        private void thốngKêNgàyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TKNhap nhap = new TKNhap();
            nhap.chuyendl(id,"d");
            nhap.Show();
            this.Close();
        }

        private void thêmNgườiDùngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddUser adduser = new AddUser();
            adduser.chuyendl(id);
            adduser.Show();
            this.Close();
        }

        private void quảnLýSảnPhẩmToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QLSP ql = new QLSP();
            ql.chuyendl(id);
            ql.Show();
            this.Close();
        }

        private void trongTuầnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Trend trend = new Trend();
            trend.chuyendl(id, "w");
            trend.Show();
            this.Close();
        }

        private void trongThángToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Trend trend = new Trend();
            trend.chuyendl(id, "m");
            trend.Show();
            this.Close();
        }

        private void thốngKêTuầnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TKNhap nhap = new TKNhap();
            nhap.chuyendl(id, "w");
            nhap.Show();
            this.Close();
        }

        private void thêmHàngMớiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddSP addsp = new AddSP();
            addsp.chuyendl(id, "");
            addsp.Show();
            this.Close();
        }

        
    }
}
